<?#//v.3.0.0
#///////////////////////////////////////////////////////
#//  COPYRIGHT 2004 Phpauction.org ALL RIGHTS RESERVED//
#///////////////////////////////////////////////////////

include '../includes/config.inc.php';
include $include_path.'dates.inc.php';
include $include_path.'auction_types.inc.php';
include "loggedin.inc.php";


#// If $id is not defined -> error
if(!isset($_GET['id']))
{
	print $MSG__0164;
	exit;
}

#// Retrieve auction's data
$query = "SELECT * FROM PHPAUCTIONXL_auctions WHERE id=".intval($_GET['id']);
$res = @mysql_query($query);
if(!$res)
{
	print "$query<BR>".mysql_error();
	exit;
}
elseif(@mysql_num_rows($res) == 0)
{
	print $MSG__0165;
}
else
{
	$AUCTION = mysql_fetch_array($res);
}

#// Retrieve winners
$query = "SELECT * FROM PHPAUCTIONXL_winners WHERE auction=".intval($_GET['id']);
$res = @mysql_query($query);
//print $query;
if(!$res)
{
	print "$query<BR>".mysql_error();
	exit;
}
elseif(mysql_num_rows($res) > 0)
{
	while($row = mysql_fetch_array($res))
	{
		$WINNERS[$row['id']] = $row;
	}
}
#// Retrieve bids
$query = "SELECT * FROM PHPAUCTIONXL_bids WHERE auction=".intval($_GET['id']);
$res = @mysql_query($query);
//print $query;
if(!$res)
{
	print "$query<BR>".mysql_error();
	exit;
}
elseif(mysql_num_rows($res) > 0)
{
	while($row = mysql_fetch_array($res))
	{
		$BIDS[$row['id']] = $row;
	}
}

?>
<HTML>
<HEAD>
<link rel='stylesheet' type='text/css' href='style.css' />
<link href="css/main.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0" class="titulo">
        <tr> 
          <td class="icono"><img src="images/auction_icon2.gif" width="31" height="25"></td>
          <td class="breadcrumbs"><p><span><?=$MSG_239?></span>&nbsp;&gt;&gt;&nbsp;<?=$MSG_30_0176?></p></td>
        </tr>
      </table></td>
  </tr>
  <tr>
    <td align="center" valign="middle">&nbsp;</td>
  </tr>
    <tr> 
    <td align="center" valign="middle">

<TABLE WIDTH="95%" BORDER="0" CELLSPACING="0" CELLPADDING="0" class="base" ALIGN="CENTER" style="border:1px solid #ccc;">
	<TR>
		<TD ALIGN=CENTER class=title>
			<p><? print $MSG_30_0176; ?></p>
		</TD>
	</TR>
	<TR>
		<TD>

    <TABLE WIDTH=100% CELPADDING=4 CELLSPACING=0 BORDER=0 ALIGN="CENTER" CELLPADDING="0">
      <TR BGCOLOR="#FFFFFF">
        <TD ALIGN=left><p><B><?=$MSG_113?>: </B> <?=intval($_GET['id'])?></p></TD>
	  </TR>
      <TR BGCOLOR="#eee">
        <TD ALIGN=left><p><B><?=$MSG_197?>: </B> <?=stripslashes($AUCTION['title'])?></p></TD>
	  </TR>
      <TR BGCOLOR="#FFFFFF">
        <TD ALIGN=left>
			<p><?$SELLER = @mysql_fetch_array(@mysql_query("SELECT name,nick FROM PHPAUCTIONXL_users WHERE id=".$AUCTION['user']));?>
			<B><?=$MSG_125?>: </B> <?=stripslashes($SELLER['nick'])." (".$SELLER['name'].")";?></p></TD>
	  </TR>
      <TR BGCOLOR="#eee">
        <TD ALIGN=left><p><B><?=$MSG_127?>: </B> <?=print_money($AUCTION['minimum_bid'])?></p></TD>
	  </TR>
      <TR BGCOLOR="#FFFFFF">
        <TD ALIGN=left><p><B><?=$MSG_111?>: </B> <?=FormatDate($AUCTION['starts'])?></p></TD>
	  </TR>
      <TR BGCOLOR="#eee">
        <TD ALIGN=left><p><B><?=$MSG_30_0177?>: </B> <?=FormatDate($AUCTION['ends'])?></p></TD>
	  </TR>
      <TR BGCOLOR="#FFFFFF">
        <TD ALIGN=left><p><B><?=$MSG_257?>: </B> <?=$auction_types[$AUCTION['auction_type']]?></p></TD>
	  </TR>
      <TR BGCOLOR="#FFFFFF">
        <TD ALIGN=left>&nbsp;</TD>
	  </TR>
      <TR>
        <TD ALIGN=left class="title"><p><?=$MSG_453?></p></TD>
	  </TR>
      <TR BGCOLOR="#FFFFFF">
        <TD ALIGN=left>
		<?
		if(is_array($WINNERS)){
		?>
				<TABLE WIDTH=65% ALIGN=CENTER CELLPADDING=4 CELLSPACING=1 BORDER=0 BGCOLOR=#FFFFFF>
				<TR BGCOLOR=#eee align=center>
					<TD><p class="blue"><B><?=$MSG_176?></B></p></TD>
					<TD><p class="blue"><B><?=$MSG_30_0179?></B></p></TD>
					<TD><p class="blue"><B><?=$MSG_284?></B></p></TD>
				</TR>
			<?
				while(list($k,$v) = each($WINNERS)){
					$qty = @mysql_result(@mysql_query("SELECT quantity FROM PHPAUCTIONXL_bids WHERE bidder=".$v['winner']." AND auction=".intval($_GET['id'])),0,"quantity");
					$BIDDER = @mysql_fetch_array(@mysql_query("SELECT name,nick FROM PHPAUCTIONXL_users WHERE id=".$v['winner']));
			?>
				<TR>
					<TD><a href="edituser.php?userid=<? print $v['winner']; ?>&offset=0" ><?=stripslashes($BIDDER['nick'])." (".stripslashes($BIDDER['name']).")"?> <BR>Click Here For Winner Details.</a></TD>
					<TD align=right><?=Print_money($v['bid'])?>&nbsp;</TD>
					<TD align=center><?if($qty==0) print "--"; else print $qty;?></TD>
				</TR>
			<?
				}
			?>
				</TABLE>
			<?
		}else{
			print $MSG_30_0178;
		}
		?>
		</TD>
	  </TR>
	  
	  
      <TR>
        <TD ALIGN=left class="title"><p><?=$MSG_30_0180?></p></TD>
	  </TR>
      <TR BGCOLOR="#FFFFFF">
        <TD ALIGN=left>
		<?
		if(is_array($BIDS)){
		?>
				<TABLE WIDTH=65% ALIGN=CENTER CELLPADDING=4 CELLSPACING=1 BORDER=0 BGCOLOR=#FFFFFF>
				<TR BGCOLOR=#eee align=center>

        To View Complete Bid History, <a href="viewwinners_complete_bid_history.php?id=<? print $_GET['id']; ?> ><font color=blue >Click Here</font></A>


</TD>
				</TR>
		
				</TABLE>
			<?
		}else{
			print $MSG_30_0178;
		}
		?>
		</TD>
	  </TR>
	  
    </TABLE>
</TR>
</TABLE>
</BODY>
<HTML>